const pool = require("../connection/sqlPool");

async function GETFLASH(numRecommendations) {
    const promisePool = pool.promise();
    try {
        const [row_id, filed_id] = await promisePool.query('SELECT `id` FROM `Tag` where `Tag_name` = "肉食" and `num` = 1');
        const selectedRecommendations = [];

        for (let j = 0; j < numRecommendations; j++) {
            const publishId = row_id[j].id;
            const [rows, fileds] = await promisePool.query('SELECT foodname, ingredients FROM `Publish_temporary_storage` where `id` = ?', [publishId]);
            selectedRecommendations.push(rows[0]); 
        }
        return selectedRecommendations;

    } catch (err) {
        return err.message;
    }
}

module.exports = { GETFLASH };
